//
//  CKBBean.m
//  JJICar
//
//  Created by 朱维坚 on 16/3/17.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "CKBBean.h"


@implementation CKBWebAPIResult{
    id            _resultObject;
    Class         _resultClass;
}

@synthesize Message;
@synthesize ExceptionMessage;
@synthesize Success;
@synthesize Result=_result;
@synthesize resultClass=_resultClass;
@synthesize resultObject = _resultObject;
@synthesize successI;
@synthesize SessionState;

- (void)setResult:(NSObject *)Result{
    
    _result = nil;
    if (![Result isKindOfClass:[NSNull class]]) {
        _result = Result ;
    }
}

- (void)setResultClass:(Class)resultClass{
    if (self.Result) {
        
        NSString *ss = NSStringFromClass(resultClass);
        if ([ss isEqualToString:@"NSNull"]) {
            self.resultObject = self.Result;
            return;
        }
        if ([self.Result isKindOfClass:[NSDictionary class]]) {
            self.resultObject = [(NSDictionary*)self.Result objectForClass:resultClass];
        }else if ([self.Result isKindOfClass:[NSArray class]]){
            self.resultObject = [resultClass objectsFromArray:self.Result];
        }else if ([self.Result isKindOfClass:[NSNull class]]){
            self.resultObject = nil;
        }else{
            self.resultObject = self.Result;
        }
    }
}

- (NSInteger)successI{
    return [self.Success integerValue];
}

- (NSInteger)error_codeI{
    return [self.SessionState integerValue];
}

- (void)dealloc
{
    self.Message = nil;
    self.Result = nil;
    self.Success = nil;
    self.SessionState = nil;
    self.ExceptionMessage = nil;
    self.resultObject = nil;
    HM_SUPER_DEALLOC();
}

@end


@implementation CKBBean

+ (void)logModel{
#if (__ON__ == __HM_DEVELOPMENT__)
    NSDictionary *resultDic = [NSDictionary dictionaryWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"ModelResultClass" withExtension:@"plist"]];
    
    for (NSString *command in resultDic.allKeys) {
        
        NSDictionary *data = [resultDic objectForKey:command];
        NSDictionary *sample = [[data objectForKey:@"output"] JSONObject];
        NSDictionary *input = [[data objectForKey:@"input"] JSONObject];
        BOOL ok = [[data objectForKey:@"ok"] boolValue];
        if (ok) {
            continue;
        }
        CC( [self.class description],@"#pragma mark - ===========prit===========  ",command,@"",@"\n/*%@%@*/",[data objectForKey:@"des"],[data objectForKey:@"input"]);
        
        NSMutableString *as_string = [NSMutableString stringWithFormat:@"#pragma mark %@\nAS_STRING(%@)\n",command,command];
        NSMutableString *def_string = [NSMutableString stringWithFormat:@"#pragma mark %@\nDEF_STRING(%@,@\"%@\")\n",command,command,command];
        NSMutableString *restore_string = [NSMutableString stringWithFormat:@"#pragma mark %@\n- (void)doReset%@Attributes:(NSArray *)attributeBinded{\n\n}\n- (BOOL)doVerity%@Attributes:(NSArray*)attributeBinded{\n\nreturn YES;\n}\n- (id)do%@Attributes:(NSDictionary *)attributeBinded{\n\n",command,command,command,command];
        NSMutableString *send_string = [NSMutableString stringWithFormat:@"\nNSDictionary *dic = @{\n"];
        NSMutableString *test_string = [NSMutableString stringWithFormat:@"\n#ifdef DEBUG\n"];
        
        NSString * send_string_bg = [NSString stringWithFormat:@"};\n[self.api postOrGet:YES paras:dic to:@\"%@\" alias:[self %@] encrypt:YES asData:dataTypeAsData form:self];\nreturn nil;",command,command];
        
        for (NSString *key in input.allKeys) {
            [as_string appendFormat:@"AS_STRING(%@IO_%@)\n",command,key];
            [def_string appendFormat:@"DEF_STRING(%@IO_%@,@\"%@IO_%@\")\n",command,key,command,key];
            [restore_string appendFormat:@"NSString *  %@ = [self doReStore:self.%@IO_%@];\n",key,command,key];
            [test_string appendFormat:@"%@ = @\"%@\";\n",key,[input valueForKey:key]];
            [send_string appendFormat:@"@\"%@\":%@,\n",key,key];
        }
#if (__ON__ == __HM_DEVELOPMENT__)
        CC( [self.class description],@"=====asstring=====\n",as_string,@"=====defstring=====\n",def_string,restore_string,test_string,@"\n#endif",send_string,send_string_bg,@"\n}");
#endif	// #if (__ON__ == __BEE_DEVELOPMENT__)
        if (!ok) {
            [sample pritfMemberForClassName:command coding:NO numberAnalysis:NO];
        }
        
    }
#endif	// #if (__ON__ == __BEE_DEVELOPMENT__)
}

+ (NSDictionary*)classNames{
    return @{@"GetTermianlInfo":[TermianlInfo class],
             @"GetLastGpsItem":[LastGpsItem class],
             @"GpsItemList":[GpsItemList class],
             @"QueryAreaSetting":[QueryAreaSetting class],
             @"DelAreaSetting":[DelAreaSetting class],
             @"AreaSetting":[AreaSetting class],
             @"DeviceBinding":[DeviceBinding class],
             @"GetPublicParam":[GetPublicParam class],
             @"SendCommand":[SendCommand class],
             @"SearchMediaFileLastTimeItem":[SearchMediaFileLastTimeItem class],
             @"Item":[Item class],
             @"SearchMediaFilesByTimes":[SearchMediaFilesByTimes class],
             @"SearchMediaFiles":[SearchMediaFiles class],
             @"GetCardInfo":[GetCardInfo class]
             };
}
@end


@implementation TermianlInfo

@synthesize TermianlNumber;
@synthesize TerminalTypeDescription;
@synthesize CreateTime;
@synthesize UserToken;
@synthesize SIM;
@synthesize ContactTel;
@synthesize Name;
@synthesize VehicleNumber;
@synthesize isOneRegister;
@synthesize IsDeafault;
@synthesize LoginName;
@synthesize Token;
@synthesize UpdateTime;
@synthesize CardNo;
@synthesize Phone;
@synthesize Remark;
@synthesize ID;
@synthesize TerminaType;
@synthesize UserId;
@synthesize HeadPhotoUrl;
@synthesize WxPublicNo;
@synthesize OpenId;

- (void)dealloc
{
    self.TermianlNumber=nil;
    self.TerminalTypeDescription=nil;
    self.CreateTime=nil;
    self.UserToken=nil;
    self.SIM=nil;
    self.ContactTel=nil;
    self.Name=nil;
    self.VehicleNumber=nil;
    self.isOneRegister=nil;
    self.IsDeafault=nil;
    self.LoginName=nil;
    self.Token=nil;
    self.UpdateTime=nil;
    self.CardNo=nil;
    self.Phone=nil;
    self.Remark=nil;
    self.ID=nil;
    self.TerminaType=nil;
    self.UserId=nil;
    self.HeadPhotoUrl=nil;
    self.WxPublicNo=nil;
    self.OpenId=nil;
    
    HM_SUPER_DEALLOC();
}

@end

@implementation LastGpsItem
@synthesize Lon;
@synthesize Lat;
@synthesize City;
@synthesize Rotation;
@synthesize ReceivedTime;
@synthesize LocateTime;
@synthesize Direction;
@synthesize Speed;
@synthesize ACCOn;
@synthesize Mileage;
@synthesize TerminalNo;
@synthesize LocationInfo;
@synthesize Status;
@synthesize LocationModel;
-(void)dealloc{
    self.Lon = nil;
    self.Lat = nil;
    self.City = nil;
    self.Rotation = nil;
    self.Speed = nil;
    self.ACCOn = nil;
    self.Mileage = nil;
    self.ReceivedTime = nil;
    self.LocateTime = nil;
    self.Direction = nil;
    self.TerminalNo = nil;
    self.LocationInfo = nil;
    self.LocationModel = nil;
    self.Status = nil;
    HM_SUPER_DEALLOC();
}
@end


@implementation GpsItemList
@synthesize Lon;
@synthesize Lat;
@synthesize City;
@synthesize Rotation;
@synthesize ReceivedTime;
@synthesize LocateTime;
@synthesize Direction;
@synthesize Speed;
@synthesize ACCOn;
@synthesize TerminalNo;
@synthesize LocationInfo;
@synthesize Mileage;
-(void)dealloc{
    self.Lon = nil;
    self.Lat = nil;
    self.City = nil;
    self.Rotation = nil;
    self.Speed = nil;
    self.ACCOn = nil;
    self.Mileage = nil;
    self.ReceivedTime = nil;
    self.LocateTime = nil;
    self.Direction = nil;
    self.TerminalNo = nil;
    self.LocationInfo = nil;
    HM_SUPER_DEALLOC();
    
}
@end

#pragma mark - LonlatItems
@implementation LonlatItems
@synthesize Lat;
@synthesize Lon;

- (void)dealloc
{
    self.Lat=nil;
    self.Lon=nil;
    
    HM_SUPER_DEALLOC();
}

@end

#pragma mark - TimeRangeItems
@implementation TimeRangeItems
@synthesize Begin;
@synthesize End;

- (void)dealloc
{
    self.Begin=nil;
    self.End=nil;
    
    HM_SUPER_DEALLOC();
}

@end

#pragma mark - RecordItems
@implementation RecordItems
@synthesize Radius;
@synthesize AreaType;
@synthesize AreaId;
@synthesize OffsetLon;
@synthesize AlarmType;
@synthesize OffsetLat;
@synthesize AreaName;
@synthesize CityCode;
@synthesize LonlatItems;
DEF_CONVERTPROPERTY_2_CLASS(LonlatItems, [LonlatItems class])
@synthesize TimeRangeItems;
DEF_CONVERTPROPERTY_2_CLASS(TimeRangeItems, [TimeRangeItems class])

- (void)dealloc
{
    self.Radius=nil;
    self.AreaType=nil;
    self.AreaId=nil;
    self.OffsetLon=nil;
    self.AlarmType=nil;
    self.OffsetLat=nil;
    self.AreaName=nil;
    self.CityCode=nil;
    self.LonlatItems=nil;
    self.TimeRangeItems=nil;
    
    HM_SUPER_DEALLOC();
}

@end

#pragma mark - QueryAreaSetting
@implementation QueryAreaSetting
@synthesize Success;
@synthesize Error;
@synthesize Time;
@synthesize RecordItems;
DEF_CONVERTPROPERTY_2_CLASS(RecordItems, [RecordItems class])
-(void)dealloc{
    self.Success = nil;
    self.Error = nil;
    self.Time = nil;
    self.RecordItems = nil;
    HM_SUPER_DEALLOC();
}
@end


#pragma mark - DelAreaSetting
@implementation DelAreaSetting
@synthesize AreaType;
@synthesize OffsetLat;
@synthesize AlarmType;
@synthesize CityCode;
@synthesize OffsetLon;
@synthesize CommandType;
@synthesize AreaName;
@synthesize Success;
@synthesize Time;
@synthesize TerminalKey;
@synthesize Errors;
@synthesize AreaId;

- (void)dealloc
{
    self.AreaType=nil;
    self.OffsetLat=nil;
    self.AlarmType=nil;
    self.CityCode=nil;
    self.OffsetLon=nil;
    self.CommandType=nil;
    self.AreaName=nil;
    self.Success=nil;
    self.Time=nil;
    self.TerminalKey=nil;
    self.Errors=nil;
    self.AreaId=nil;
    HM_SUPER_DEALLOC();
}
@end


#pragma mark - AreaSetting
@implementation AreaSetting
@synthesize AreaType;
@synthesize OffsetLat;
@synthesize AlarmType;
@synthesize CityCode;
@synthesize OffsetLon;
@synthesize CommandType;
@synthesize AreaName;
@synthesize Success;
@synthesize Time;
@synthesize TerminalKey;
@synthesize Errors;
@synthesize AreaId;

- (void)dealloc
{
    self.AreaType=nil;
    self.OffsetLat=nil;
    self.AlarmType=nil;
    self.CityCode=nil;
    self.OffsetLon=nil;
    self.CommandType=nil;
    self.AreaName=nil;
    self.Success=nil;
    self.Time=nil;
    self.TerminalKey=nil;
    self.Errors=nil;
    self.AreaId=nil;
    HM_SUPER_DEALLOC();
}
@end

#pragma mark - GetPublicParam
@implementation GetPublicParam
@synthesize FuncName;
@synthesize CreaterId;
@synthesize FuncValue;
@synthesize OperateId;
@synthesize Id;

- (void)dealloc
{
    self.FuncName=nil;
    self.CreaterId=nil;
    self.FuncValue=nil;
    self.OperateId=nil;
    self.Id=nil;
    HM_SUPER_DEALLOC();
}
@end

#pragma mark - DeviceBinding
@implementation DeviceBinding
@synthesize TermianlNumber;
@synthesize TerminalTypeDescription;
@synthesize CreateTime;
@synthesize UserToken;
@synthesize SIM;
@synthesize ContactTel;
@synthesize Name;
@synthesize VehicleNumber;
@synthesize isOneRegister;
@synthesize IsDeafault;
@synthesize UpdateTime;
@synthesize LoginName;
@synthesize Token;
@synthesize CardNo;
@synthesize Phone;
@synthesize Remark;
@synthesize ID;
@synthesize TerminaType;
@synthesize UserId;
@synthesize HeadPhotoUrl;
@synthesize WxPublicNo;
@synthesize OpenId;

- (void)dealloc
{
    self.TermianlNumber=nil;
    self.TerminalTypeDescription=nil;
    self.CreateTime=nil;
    self.UserToken=nil;
    self.SIM=nil;
    self.ContactTel=nil;
    self.Name=nil;
    self.VehicleNumber=nil;
    self.isOneRegister=nil;
    self.IsDeafault=nil;
    self.UpdateTime=nil;
    self.LoginName=nil;
    self.Token=nil;
    self.CardNo=nil;
    self.Phone=nil;
    self.Remark=nil;
    self.ID=nil;
    self.TerminaType=nil;
    self.UserId=nil;
    self.HeadPhotoUrl=nil;
    self.WxPublicNo=nil;
    self.OpenId=nil;
    HM_SUPER_DEALLOC();
}
@end

#pragma mark - SendCommand
@implementation SendCommand
@synthesize CmdSendTime;
@synthesize CommandState;
@synthesize commandType;
@synthesize Result;
@synthesize TerminalId;

- (void)dealloc
{
    self.CmdSendTime=nil;
    self.CommandState=nil;
    self.commandType=nil;
    self.Result=nil;
    self.TerminalId=nil;
    HM_SUPER_DEALLOC();
}
@end

#pragma mark - SearchMediaFileLastTimeItem
@implementation SearchMediaFileLastTimeItem
@synthesize Length;
@synthesize FileTime;
@synthesize ReceiveTime;

- (void)dealloc
{
    self.Length=nil;
    self.FileTime=nil;
    self.ReceiveTime=nil;
    HM_SUPER_DEALLOC();
}
@end

#pragma mark - Item
@implementation Item
@synthesize TextLocation;
@synthesize Lon;
@synthesize Lat;
@synthesize FileType;
@synthesize CityCode;
@synthesize StatusType;
@synthesize RoadType;
@synthesize City;

- (void)dealloc
{
    self.TextLocation=nil;
    self.Lon=nil;
    self.Lat=nil;
    self.FileType=nil;
    self.CityCode=nil;
    self.StatusType=nil;
    self.RoadType=nil;
    self.City=nil;
    HM_SUPER_DEALLOC();
}
@end

#pragma mark - SearchMediaFilesByTimes
@implementation SearchMediaFilesByTimes
@synthesize Length;
@synthesize FileUrl;
@synthesize ReceiveTime;
@synthesize FileTime;
@synthesize TerminalKey;
@synthesize Item;
DEF_CONVERTPROPERTY_2_CLASS(Item, [Item class])
@synthesize ShareShortUrl;

- (void)dealloc
{
    self.Length=nil;
    self.FileUrl=nil;
    self.ReceiveTime=nil;
    self.FileTime=nil;
    self.TerminalKey=nil;
    self.Item=nil;
    self.ShareShortUrl=nil;
    HM_SUPER_DEALLOC();
}
@end

#pragma mark - SearchMediaFiles
@implementation SearchMediaFiles
@synthesize Length;
@synthesize FileUrl;
@synthesize ReceiveTime;
@synthesize FileTime;
@synthesize TerminalKey;
@synthesize Item;
DEF_CONVERTPROPERTY_2_CLASS(Item, [Item class])
@synthesize ShareShortUrl;

- (void)dealloc
{
    self.Length=nil;
    self.FileUrl=nil;
    self.ReceiveTime=nil;
    self.FileTime=nil;
    self.TerminalKey=nil;
    self.Item=nil;
    self.ShareShortUrl=nil;
    HM_SUPER_DEALLOC();
}
@end


#pragma mark - TariffPackagesInfo
@implementation TariffPackagesInfo
@synthesize GuidePrice;
@synthesize Id;
@synthesize DefaultPrice;
@synthesize Flow;
@synthesize TariffName;
@synthesize FlowCycle;
@synthesize ServiceCycle;

- (void)dealloc
{
    self.GuidePrice=nil;
    self.Id=nil;
    self.DefaultPrice=nil;
    self.Flow=nil;
    self.TariffName=nil;
    self.FlowCycle=nil;
    self.ServiceCycle=nil;
    
    HM_SUPER_DEALLOC();
}

@end

#pragma mark - GetCardInfo
@implementation GetCardInfo
@synthesize Agency4ID;
@synthesize Code;
@synthesize OpenCardDate;
@synthesize Agency1ID;
@synthesize CardCustomer;
@synthesize CompanyId;
@synthesize Agency2ID;
@synthesize Agency3ID;
@synthesize CreateTime;
@synthesize Agency5ID;
@synthesize SIM;
@synthesize ShortMsgPackages;
@synthesize UseMsgCount;
@synthesize FlowCycle;
@synthesize IMSI;
@synthesize MonthFlow;
@synthesize BrandID;
@synthesize TariffPackagesInfo;
DEF_CONVERTPROPERTY_2_CLASS(TariffPackagesInfo, [TariffPackagesInfo class])
@synthesize LoginName;
@synthesize TName;
@synthesize Error;
@synthesize ServiceStartDate;
@synthesize ServiceEndDate;
@synthesize CardSource;
@synthesize ActivePeriod;
@synthesize Flow;
@synthesize CardState;
@synthesize PublicNo;
@synthesize ICCID;

- (void)dealloc
{
    self.Agency4ID=nil;
    self.Code=nil;
    self.OpenCardDate=nil;
    self.Agency1ID=nil;
    self.CardCustomer=nil;
    self.CompanyId=nil;
    self.Agency2ID=nil;
    self.Agency3ID=nil;
    self.CreateTime=nil;
    self.Agency5ID=nil;
    self.SIM=nil;
    self.ShortMsgPackages=nil;
    self.UseMsgCount=nil;
    self.FlowCycle=nil;
    self.IMSI=nil;
    self.MonthFlow=nil;
    self.BrandID=nil;
    self.TariffPackagesInfo=nil;
    self.LoginName=nil;
    self.TName=nil;
    self.Error=nil;
    self.ServiceStartDate=nil;
    self.ServiceEndDate=nil;
    self.CardSource=nil;
    self.ActivePeriod=nil;
    self.Flow=nil;
    self.CardState=nil;
    self.PublicNo=nil;
    self.ICCID=nil;
    
    HM_SUPER_DEALLOC();
}

@end